package demo.metrics;

import java.util.function.ToDoubleFunction;

import util.MetricsUtil;

public class CountMapToDouble implements ToDoubleFunction<String>{
	private final String key;
	public CountMapToDouble(String key){
		this.key = key;
	}
	
	@Override
	public double applyAsDouble(String obj){
		if(key==null){
			return 0;
		}
		Long v = MetricsUtil.get(key);
		if(v==null){
			return 0;
		}
		return v.doubleValue();
	}
	
	
	
}